package cn.demoncat.util.kafka.entity;

import cn.demoncat.util.mq.entity.MqCallback;
import org.springframework.kafka.support.SendResult;
import org.springframework.util.concurrent.ListenableFutureCallback;

/**
 * Kafka的消息发送回调
 *
 * @author 延晓磊
 * @since 2021年02月17日
 */
public class KafkaMqCallback implements ListenableFutureCallback<SendResult<String, String>> {

    private final MqCallback callback;

    public KafkaMqCallback(MqCallback callback) {
        this.callback = callback;
    }

    @Override
    public void onFailure(Throwable ex) {
        callback.onFailure(ex);
    }

    @Override
    public void onSuccess(SendResult<String, String> result) {
        callback.onSuccess();
    }
}
